namespace QMVnSoft.Lists
{
    using QMVnSoft;
    using QMVnSoft.Controls;
    using QMVnSoft.DAL;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FormDmHdLister : FormListLister
    {
        private IContainer components;
        private bool ib_KeyCtrlF3;

        public FormDmHdLister()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            base.SuspendLayout();
            base.AutoScaleDimensions = new SizeF(6f, 13f);
            base.ClientSize = new Size(0x2bd, 0x10a);
            base.LocalFieldName = "MA_HD";
            base.LocalTableName = "DMHD";
            base.Name = "FormDmHdLister";
            base.OrderFieldNames = "MA_HD";
            this.Text = "Danh mục hợp đồng";
            base.ResumeLayout(false);
            base.PerformLayout();
        }

        public override bool OnAdd()
        {
            base.LocalFormEditor = new FormDmHdEditor();
            return base.OnAdd();
        }

        public override bool OnEdit()
        {
            if (this.ib_KeyCtrlF3)
            {
                base.LocalFormEditor = new FormDmHdVtEditor();
                this.ib_KeyCtrlF3 = false;
            }
            else
            {
                base.LocalFormEditor = new FormDmHdEditor();
            }
            return base.OnEdit();
        }

        public override void OnFillData()
        {
            object[][] objArray = new object[10][];
            object[] objArray2 = new object[4];
            objArray2[0] = "Ma_Hd";
            objArray2[1] = "Hợp đồng";
            objArray2[2] = "C";
            objArray[0] = objArray2;
            object[] objArray3 = new object[4];
            objArray3[0] = "Ten_Hd";
            objArray3[1] = "Tên hợp đồng";
            objArray3[2] = "C";
            objArray[1] = objArray3;
            object[] objArray4 = new object[4];
            objArray4[0] = "Loai_Hd";
            objArray4[1] = "Loại";
            objArray4[2] = "C";
            objArray[2] = objArray4;
            object[] objArray5 = new object[4];
            objArray5[0] = "Ngay_Ky";
            objArray5[1] = "Ngày ký";
            objArray5[2] = "C";
            objArray[3] = objArray5;
            object[] objArray6 = new object[4];
            objArray6[0] = "Tk";
            objArray6[1] = "Tài khoản";
            objArray6[2] = "C";
            objArray[4] = objArray6;
            object[] objArray7 = new object[4];
            objArray7[0] = "Ma_Dt";
            objArray7[1] = "Đối tượng";
            objArray7[2] = "C";
            objArray[5] = objArray7;
            objArray[6] = new object[] { "TTien0", "Giá trị", "N", AppInstance.TextNumericFormat.LocalAmount };
            objArray[7] = new object[] { "TTien_Nt0", "Giá trị nguyên tệ", "N", AppInstance.TextNumericFormat.ForeignAmount };
            objArray[8] = new object[] { "TTien", "Giá trị còn lại", "N", AppInstance.TextNumericFormat.LocalAmount };
            objArray[9] = new object[] { "TTien_Nt", "Giá trị còn lại nguyên tệ", "N", AppInstance.TextNumericFormat.ForeignAmount };
            base.ColNames = objArray;
            base.OnFillData();
        }

        public override void OnRefresh()
        {
            base.LocalDataSet = new DmHdDataAccess().GetDataSet();
            base.OnRefresh();
        }

        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (keyData == (Keys.Control | Keys.F3))
            {
                this.ib_KeyCtrlF3 = true;
                this.OnEdit();
                return true;
            }
            this.ib_KeyCtrlF3 = false;
            return base.ProcessCmdKey(ref msg, keyData);
        }
    }
}

